package com.xnj.transform_stream;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

// 字符输入转换流
public class InputStreamReaderTest {
    public static void main(String[] args) {
        try (
                // 1. 得到文件的原始字节输入流
                FileInputStream frd = new FileInputStream("src/转换流gbk.txt");
                // 2. 把原始字节输入流按指定字符集进行转换成字符输入流
                InputStreamReader in = new InputStreamReader(frd, "GBK");
                // 3. 把字符输入流包装成字符缓冲输入流
                BufferedReader br = new BufferedReader(in);
        ){

            String line ;
            while ((line = br.readLine())!=null){
                System.out.println(line);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
